package com.hspedu.sqlsession;

import java.lang.reflect.Proxy;

public class HspSqlSession {
    //属性
    //执行器
    private Executor executor = new HspExecutor();
    //配置
    private HspConfiguration hspConfiguration = new HspConfiguration();

    public <T>T selectOne(String statement,Object parameter){
        return executor.query(statement, parameter);
    }

    @SuppressWarnings("unchecked")
    public <T>T getMapper(Class<T> clas) {
        //动 态 代 理 调 用
        return (T) Proxy.newProxyInstance(clas.getClassLoader(), new Class[]{clas},new HspMapperProxy(hspConfiguration, this, clas));
    }
}
